﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.UI;

namespace HyMaterialStatistic
{
	public class GridApplication : IExternalApplication
	{
		public Result OnShutdown(UIControlledApplication application)
		{
			if (GridApplication.m_dlgMainSet != null && GridApplication.m_dlgMainSet.Visible)
			{
				GridApplication.m_dlgMainSet.Close();
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		public Result OnStartup(UIControlledApplication application)
		{
			GridApplication.m_dlgMainSet = null;
			GridApplication.thisApp = this;
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		public void ShowForm(ExternalCommandData command, GridRequestHandlerParent handler, ExternalEvent exEvent, DlgMaterialStatisticParent dlgFilter, MepGridManagerParent gridMag, MEP_SPECIALITY speciality, List<string> lstGrid)
		{
			if (GridApplication.m_dlgMainSet == null || GridApplication.m_dlgMainSet.IsDisposed)
			{
				GridApplication.m_dlgMainSet = new DlgSpecialtyStatisticTable(command, exEvent, handler, WindowHelper.HWndRevit, speciality, dlgFilter, gridMag, lstGrid);
			}
			GridApplication.m_dlgMainSet.Show(WindowHelper.HWndRevit);
		}

		public static GridApplication thisApp;

		public static DlgSpecialtyStatisticTable m_dlgMainSet;
	}
}
